import unittest
from script.test01_img_verify_code import TestImgVerifyCode
from script.test02_sms_code import TestSmsCode
from script.test03_reg import TestReg
from script.test04_login import TestLogin
import app
from lib.HTMLTestRunner import HTMLTestRunner

# 创建测试套件，组装测试用例
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestImgVerifyCode))
suite.addTest(unittest.makeSuite(TestSmsCode))
suite.addTest(unittest.makeSuite(TestReg))
suite.addTest(unittest.makeSuite(TestLogin))

# unittest.TextTestRunner().run(suite)

# 定义测试报告文件路径
report_file = app.BASE_DIR + "/report/report.html"

# 打开文件流
with open(report_file, "wb") as f:
    # 创建运行器对象
    runner = HTMLTestRunner(f, title="P2P项目接口自动化测试报告", description="...")
    # 执行测试套件
    runner.run(suite)
